1. Field of Invention
This disclosure generally relates to virtual machines. More specifically, this disclosure relates to techniques that facilitate managing translated program code in a virtual machine that supports self-modifying program code.
2. Related Art
Virtual machines can be used to emulate different hardware environments on the physical hardware of a computing device. For instance, a virtual machine can facilitate executing programs that have been compiled for a different instruction set architecture (ISA) than that of the computing device. Moreover, two or more virtual machines that emulate different hardware environments and/or operating systems may co-exist and simultaneously execute guest programs on the same computing device.
Program instructions specified in a “guest” ISA typically need to be translated before they can execute in the native ISA of a computing device. For instance, a dynamic compiler can analyze blocks of guest instructions in a guest program and can then compile (or “translate”) these guest instructions into a sequence of optimized native ISA instructions which, when executed, achieve the same results as the original guest program. These translated native ISA instructions are maintained in a code cache, and can be executed by multiple instances of the guest program. However, caching such translated native ISA instructions can be problematic when guest program code changes during execution. For instance, self-modifying guest program code may change instructions in the guest program code, thereby resulting in a cached set of translated native ISA instructions that no longer match the modified guest program code.
Hence, what is needed are structures and methods that facilitate executing guest programs in a virtual machine without the above-described problem.